<template>
  <div>
      <div id="detail">
        <detail-nav-bar></detail-nav-bar>
        <detail-swiper :top-images="topImages"></detail-swiper>
        <detail-base-info :goods="goods"></detail-base-info>
      </div>
  </div>
</template>

<script>
import DetailNavBar from '@/views/detail/childCompos/DetailNavBar'
import DetailSwiper from '@/views/detail/childCompos/DetailSwiper'
import DetailBaseInfo from '@/views/detail/childCompos/DetailBaseInfo'

import {getDetail,Goods} from '../../network/detail'

export default {
    name:'Detail',
    components:{
        DetailNavBar,
        DetailSwiper,
        DetailBaseInfo
    },
    data(){
        return{
            iid:null,
            topImages:[],
            goods: {},
        }
    },
    created(){
        //1、保存传入的iid
        this.iid = this.$route.params.iid
        //2、根据iid请求详情数据
        getDetail(this.iid).then(res => {
            console.log(res);
            const data = res.result;
            this.topImages = res.result.itemInfo.topImages;
            this.goods = new Goods(data.itemInfo, data.columns, data.shopInfo);
        })

        
    }
}
</script>

<style>

</style>